package org.gdpu.model;

import javax.persistence.*;

/**
 * Created by HEWI2 on 1/22/14.
 */
@Entity
public class User {

    /**
     * 用户编号
     */
    private int userId;
    /**
     * 用户名
     */
    // 登录名，可有用户自由设置
    private String userName;
    /**
     * 用户密码
     */
    private String password;
    /**
     * 权限组
     */
    private PowerGroup powerGroup;
    /**
     * 宿舍
     */
    private Dormitory dormitory;

    @Id
    @GeneratedValue
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Column(nullable = false, length = 20)
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(nullable = false, length = 16)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @ManyToOne
    @JoinColumn(name = "powerGroupId", nullable = false)
    public PowerGroup getPowerGroup() {
        return powerGroup;
    }

    public void setPowerGroup(PowerGroup powerGroup) {
        this.powerGroup = powerGroup;
    }

    @OneToOne
    @JoinColumn(name = "dormitory")
    public Dormitory getDormitory() {
        return dormitory;
    }

    public void setDormitory(Dormitory dormitory) {
        this.dormitory = dormitory;
    }
}
